using System.Net.Http;

namespace demo001.Services
{
    /// <summary>
    /// HttpClient 工厂类，提供全局唯一的 HttpClient 实例
    /// </summary>
    public static class HttpClientFactory
    {
        // 使用静态构造函数确保线程安全的单例模式
        private static readonly HttpClient _httpClient;

        static HttpClientFactory()
        {
            _httpClient = new HttpClient
            {
                // 设置全局默认超时时间
                Timeout = TimeSpan.FromMinutes(10)
            };
        }

        /// <summary>
        /// 获取全局 HttpClient 实例
        /// </summary>
        public static HttpClient GetClient()
        {
            return _httpClient;
        }
    }
}